<?php //require_once("includes/header.php"); ?>

<?php //require_once("includes/profile.php"); ?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>eFace</title>
<link rel="stylesheet" media="screen" type="text/css" />
<script src="https://connect.facebook.net/en_US/all.js"></script>
</head>
<body>
<div id="wrapper">

<?php

	require ('facebook-php-sdk-2343fca/src/facebook.php');
	
	//create application instance
	$facebook = new facebook(array(
		'appid' => '188344027872191',
		'secret' => 'c7cd5f938c84c19d4d81d42f18f43fcf',
		'cookie' => true,
	));

	$session = $facebook->getSession();
	
if (!empty($session)) {
		
		try {
			$uid = $facebook->getUser();
			$user = $facebook->api('/me');
			
		} catch (Exception $e) {}
		
		if (!empty($user)) {
			
			if ($_GET['installed']=='1') {
				header("Location: http://apps.facebook.com/efacebay");
			}
			
			echo "Hello ".$user['first_name']." ". $user['last_name'];
			
			//////////////////////////////////////////////////////////
								//content_begin
			//////////////////////////////////////////////////////////
			?>
			<div id="fb-root1"></div>
	  
      <script type="text/javascript">
         FB.init({ 
            appId:'188344027872191', cookie:true, 
            status:true, xfbml:true 
         });
         FB.api('/me', function(user) {
           if(user != null) {
              var image = document.getElementById('image');
              image.src = 'http://graph.facebook.com/' + user.id + '/picture';
              var name = document.getElementById('name');
              name.innerHTML = user.name
           }
         });
       </script>
           <div id="profile">
           <img id="image"/>
           <div id="name"></div>
           </div>
		   
		<?php
			
			?>
			<p align="right" style="margin-top: -35px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fapps.facebook.com%2Fefacebay%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=recommend&amp;font=verdana&amp;colorscheme=light&amp;height=80" 
			scrolling="no" 
			frameborder="0" 
			style="border:none; overflow:hidden; width:350px; height:80px;" 
			allowTransparency="true">
			</iframe>
			</p>
		
			<?php
			require_once("search_all.php");
			?>
			<br />
			<div align="center">
			<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=188344027872191&amp;xfbml=1">
			</script>
			<fb:live-stream event_app_id="188344027872191" width="400" height="500" xid="stream_comments" via_url="http://apps.facebook.com/efacebay/" always_post_to_friends="true">
			</fb:live-stream>
			</div>
			
			<script type="text/javscript">
			FB.Event.subscribe('auth.sessionChange', function(response) {
				document.write("hello");
});
			</script>
			
			<!-- token  "send("a04d533bc831a5ba6cdf8f0279e8fe43");" -->
			
			<?php
		
			//////////////////////////////////////////////////////////
								//content_end
			//////////////////////////////////////////////////////////
			
		} else {
			die("An error has occoured");
		}
		
	/*else {
		$url = $facebook->getLoginUrl();
		echo "Click here to add the application";
	}*/
	
}

?>
</body>
 <?php //require_once("includes/footer.php"); ?>